package edu.ivanov.apm.tests;

import edu.ivanov.apm.chaos.Interpreter;
import edu.ivanov.apm.chaos.Position;
import edu.ivanov.apm.chaos.RuleProducer;
import edu.ivanov.apm.ui.*;

import java.util.HashMap;
import java.util.Map;

/**
 * User: ilya
 * Date: 11.10.13
 * Time: 22:56
 */
public class TestFractal extends DrawBoard {

    public void draw() {
        RuleProducer producer = new RuleProducer();
        producer.setAxiom("F");

        Map<Character, String> productions = new HashMap<Character, String>();
        productions.put('F', "-F+F+[+F-F-]-[-F+F+F]");
        producer.setProductions(productions);

        String rule = producer.getAxiom();
        System.out.println(rule);

        for (int i = 0; i < 5; i++) {
            rule = producer.produce(rule);
            System.out.println(rule);
        }

        PaintingTurtle turtle = new PaintingTurtle(addCanvas());
        turtle.setPosition(new Position(300, 500, 0));
        Interpreter interpreter = new Interpreter();
        interpreter.setTurtle(turtle);
        interpreter.setF(7);
        interpreter.setTheta(Math.PI / 8);

        interpreter.interpret(rule);
    }

    public static void main(String[] args) {
        UI.show(new TestFractal());
    }
}
